package com.yunhui.config.rabbitmq;



import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * mq的config 将交换机和对列绑定
 */
//此注解的类表示，我们类里面包含一个或者多个都得bean的都将会被扫描进spring容器中
@Configuration
public class MQConfig {
	/*
	
	*//**
	 * 绑定添加订单的消息列队
	 * @return
	 */
	@Bean
	public Queue QueueOrder() {
		return new Queue("queueorder");
	}


	/**
	 * 将短信的队列加载进去
	 * @return
	 *//*
	@Bean
	public Queue QueueMessage(){
		return new Queue("queuemessage");
	}
	
	*//**
	 * 配置交换器
	 * @return
	 */
	@Bean
	public TopicExchange topicExchange() {
		return new TopicExchange("topicExchange");
	}




	
	
	/**
	 * 订单
	 * 将消息列队绑定交换机在指定路由规则
	 * @param QueueOrder 消息列队
	 * @param topicExchange  交换机
	 * @return
	 */
	@Bean
	public Binding  bindingExchengeOrder(Queue QueueOrder,TopicExchange topicExchange) {
		return BindingBuilder.bind(QueueOrder).to(topicExchange).with("topic.queueorder");
	}

	/**
	 * 将短信的列队绑定交换机并指定路由规则
	 * @param QueueMessage
	 * @param topicExchange
	 * @return
	 *//*
	public Binding bindingExchengeMessage(Queue QueueMessage,TopicExchange topicExchange){
		return BindingBuilder.bind(QueueMessage).to(topicExchange).with("topic.queuemessage");
	}*/
}
